package util;

import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

public class ArrayTest {

    private static final Logger logger = LoggerFactory.getLogger(ArrayTest.class);

    @Test
    public void test1() {
        int[] num = {1, 2, 3, 54, 4};
        Arrays.fill(num, 6);
        for (int i = 0; i < num.length; i++) {
            logger.info(String.valueOf(num[i]));
        }
    }

    @Test
    public void test2() {
        //ArrayList使用数组实现的查找访问比较快
        ArrayList arrayList = new ArrayList<>();

        //LinkedList是用双向链表实现的，插入和删除比ArrayList()效率快
        LinkedList linkedList = new LinkedList();

    }

    @Test
    public void test3() {
        int[] num = {1, 2, 3, 54, 4};
        List<int[]> ints = Collections.singletonList(num);
        logger.info(JSON.toJSONString(ints));

        List<String> list = new ArrayList<>();
        list.add("张三");
        list.add("张三");
        list.add("李四");
        String[] objects = list.toArray(new String[0]);
        logger.info(JSON.toJSONString(objects));
    }
}
